/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once


#include <向量.h>
#include <矩阵.h>


/*inline void f_get摄像机矩阵(float32* mat, const vec3& 摄像机位置, const vec3& 视点, const vec3& 上方向) {
	//float32 mat[16];
	auto 临时mat = DirectX::XMMatrixLookAtLH(DirectX::XMVectorSet(摄像机位置.x, 摄像机位置.y, 摄像机位置.z, 1),
		DirectX::XMVectorSet(视点.x, 视点.y, 视点.z, 1),
		DirectX::XMVectorSet(上方向.x, 上方向.y, 上方向.z, 1)
	).r;

	memcpy(mat, 临时mat, sizeof(float32) * 16);
	
}*/

int8 f_random_I8(ivec2 区间, int32 种子);
void f_random_I8Array(S_I8Array* val, uint64 num, int8 最小, int8 最大, int32 种子);
void f_random_F32Array(S_F32Array* vec, uint64 num, float32 最小, float32 最大, int32 种子);
void f_random_I32Array(S_I32Array* vec, uint64 num, float32 最小, float32 最大, int32 种子);
void f_random_UI32Array(S_UI32Array* vec, uint64 num, uint32 最小, uint32 最大, int32 种子);

void f_random_Vec3Array(S_Vec3Array* vec, uint64 num, vec2 X, vec2 Y, vec2 Z, int32 种子);
void f_random_iVec2Array(S_iVec2Array* vec, uint64 num, const ivec2& X区间, const ivec2& Y区间, int32 种子, uint8 type);
void f_random_iVec3Array(S_iVec3Array* vec, uint64 num, const ivec3& 最小, const ivec3& 最大, int32 种子);




mat3X3	f_get坐标集包围盒(vec3* v, uint32 num);
float32	f_get坐标集包围球(vec3* v, uint32 num);


vec3 f_math_向量归一化(const vec3& dirA, uint8 type);
void f_math_向量归一化m(const S_Vec3Array* dirA, S_Vec3Array* r, uint8 type);

float32 f_math_两向量标量(const vec3& dirA, const vec3& dirB, uint8 type);
void f_math_两向量标量m(const S_Vec3Array* dirA, const S_Vec3Array* dirB, S_F32Array* r, uint8 type);

vec3 f_math_两向量叉积(const vec3& dirA, const vec3& dirB);
void f_math_两向量叉积m(const S_Vec3Array* dirA, const S_Vec3Array* dirB, S_Vec3Array* r);

void f_math_向量长度m(S_F32Array* r, const S_Vec3Array* dirA, uint8 type);

vec4 f_math_quat两向量(const vec3& dirA, const vec3& dirB);
void f_math_quat两向量m(const S_Vec3Array* dirA, const S_Vec3Array* dirB, S_Vec4Array* r);
void f_math_quat以轴向和角度构建m(S_Vec4Array* quat, const S_Vec3Array* v, const S_F32Array* a);

void f_math_quat相乘m(const S_Vec4Array* dirA, const S_Vec4Array* dirB, S_Vec4Array* r);

void f_math_quat变换m(const S_Vec3Array* dirA, const S_Vec4Array* dirB, S_Vec3Array* r, int32 方式);
void f_math_四元数转欧拉角m(const S_Vec4Array* quat, S_Vec3Array* r);
void f_math_四元数转3X3矩阵m(const S_Vec4Array* quat, S_Mat33Array* r);
void f_math_四元数转4X4矩阵m(const S_Vec4Array* quat, S_Mat44Array* r);

vec3 f_math_轴向旋转变换(vec3 point, vec3 轴向, float32 角度, int32 方式);
void f_math_轴向旋转变换m(S_Vec3Array* 新坐标, const S_Vec3Array* point, const S_Vec3Array* 轴向, S_F32Array* r, int32 方式);


void f_math_mat44_变换m(const S_Vec3Array* dirA, const S_Mat44Array* dirB, S_Vec3Array* r);
void f_math_mat44_相乘m(const S_Mat44Array* dirA, const S_Mat44Array* dirB, S_Mat44Array* r);
Mat44f f_math_mat44_相乘(const Mat44f& dirA, const Mat44f& dirB);


vec3 f_math_绕点旋转(const vec3& point, const vec3& 轴向, const float32 弧度, const vec3& 中心);
void f_math_绕点旋转m(S_Vec3Array* r, const S_Vec3Array* point, const S_Vec3Array* 轴向, const S_F32Array* 弧度, const vec3& 中心);



void f_mat_平面构建(const S_Vec3Array* point, S_Vec4Array* plane);
void f_mat_点到平面距离(const S_Vec3Array* point, const S_Vec4Array* plane, S_F32Array* 距离);
void f_mat_射线平面相交(const S_Vec3Array* point, const S_Vec4Array* plane, S_Vec3Array* 交点);








void f_math_视锥平面计算(const Mat44f& mat, vec4 planes[6]);









